package com.icloud.system.boot.controller.app;

import com.icloud.common.core.api.CommonResult;
import com.icloud.common.web.vo.FileUrlVO;
import com.icloud.system.boot.service.AppFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Api(tags = "文件服务")
@RequestMapping("/app/file")
@RequiredArgsConstructor
public class AppFileController {
    private final AppFileService appFileService;

    @ApiOperation("上传动态图片或视频")
    @PostMapping(value="/upload/article", consumes= MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    CommonResult<FileUrlVO> uploadArticle(@RequestPart(value="file") MultipartFile file) throws IOException{
        return CommonResult.success(appFileService.uploadArticle(file));
    }
}
